package com.ambow.store.controller;

import com.ambow.store.controller.util.Result;
import com.ambow.store.entity.Product;
import com.ambow.store.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("product")
public class ProductController extends BaseController {

    @Autowired
    private ProductService productService;

    @GetMapping("/gethostlist")
    public Result getHostList(){
        List<Product> hostList = productService.getHostList();
        return new Result(OK,hostList);
    }
    @GetMapping("/getproductdata/{id}")
    public Result getProductData(@PathVariable("id") Integer id){
        Product data = productService.getDataByID(id);
        return new Result(OK,data);
    }
}
